
*******************************************************************************
****						Table 5 Panel B  - Mistakes in Travel Time Savings ****
*******************************************************************************
use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear

sort month hour year
merge m:1 date hour using ".\data\clean\HV_ML_speedrobustness_I10W", keep(1 3) nogen 
merge m:1 date hour using ".\data\clean\HV_ML_reliab", keep(1 3) nogen 

gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV
egen maxELspeed=max(ELspeed), by(rt_id min hour date)
*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen TT_dif_hr_max1=dist/MLspeed-dist/maxELspeed
*gen TT_dif_hr_max1=dist/MLspeed-dist/max_speedHV
gen TT_dif_hr_max2=dist/MLspeed-dist/max_speedHV
gen TT_dif_hr_max3=dist/min_speedML-dist/ELspeed
gen TT_dif_hr_max4=dist/min_speedML-dist/max_speedHV

gen WTP2=charged_toll/TT_dif_hr
keep if WTP2>0&WTP2~=.
*keep if WTP2~=.
*keep if WTP2<0
drop if ELspeed==.
drop if TT_dif_hr==.
drop if holiday==1
drop if dow==0 | dow==6
keep if hour>4 & hour<9
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
drop if TT_dif_hr<=0

la var TT_dif_hr "Time in Hours (Baseline)"
la var TT_dif_hr_max1 "Time in Hours (max. 1)"
la var TT_dif_hr_max2 "Time in Hours (max. 2)"
la var TT_dif_hr_max3 "Time in Hours (max. 3)"
la var TT_dif_hr_max4 "Time in Hours (max. 4)"

est sto clear
g TT_dif_hr_new=TT_dif_hr*2
la var TT_dif_hr_new "Travel Time in Hours"
qui reg charged_toll  TT_dif_hr_new , cluster(rt_id)
estimates store a1

drop TT_dif_hr_new
g TT_dif_hr_new=((dist+.5)/MLspeed)-((dist+.5)/ELspeed)
la var TT_dif_hr_new "Travel Time in Hours"
qui reg charged_toll  TT_dif_hr_new , cluster(rt_id)
estimates store a2


drop TT_dif_hr_new
g TT_dif_hr_new=TT_dif_hr+7/60
la var TT_dif_hr_new "Travel Time in Hours"
qui reg charged_toll  TT_dif_hr_new , cluster(rt_id)
estimates store a3


drop TT_dif_hr_new
g TT_dif_hr_new=TT_dif_hr+14/60
la var TT_dif_hr_new "Travel Time in Hours"
qui reg charged_toll  TT_dif_hr_new , cluster(rt_id)
estimates store a4

esttab  a1 a2 a3 a4   using ".\results\appendix\tabs\ATC10pa.csv", replace  ///
label cells(b(star fmt(%9.2f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) stats(r2 N,fmt(%9.3f %9.0g) labels(R-squared N)) ///
	order(_cons TT_dif_hr_new ) nonumbers nodepvars



///Panel B

est sto clear
qui reg charged_toll TT_dif_hr_max1 , cluster(rt_id)
estimates store a2
qui reg charged_toll TT_dif_hr_max2 , cluster(rt_id)
estimates store a3
qui reg charged_toll TT_dif_hr_max3 , cluster(rt_id)
estimates store a4
qui reg charged_toll TT_dif_hr_max4 , cluster(rt_id)
estimates store a5

esttab   a2 a3 a4 a5 using ".\results\appendix\tabs\ATC10pb.csv", replace  ///
label cells(b(star fmt(%9.3f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) stats(r2 N,fmt(%9.3f %9.0g) labels(R-squared Observations)) ///
	order(_cons TT_dif_hr TT_dif_hr_max1 TT_dif_hr_max2 TT_dif_hr_max3 TT_dif_hr_max4 ) nonumbers nodepvars
preserve
insheet using ".\results\appendix\tabs\ATC10pb.csv", clear comma
tempfile temp
save `temp'
insheet using ".\results\appendix\tabs\ATC10pa.csv", clear comma
local N=_N+2
set obs `N'
append using `temp'
